package com.up2566.demo.model;

import com.up2566.demo.model.vo.ComputeVo;
import java.math.BigDecimal;

/**
 * 计算结果临时存放对象
 *
 * @author up
 * @date 2021/1/11
 */
public class ComputePojo {

    /**
     * 流派 0:纯影 1:云豪 2:七刀
     */
    private String liupai;

    private boolean sdsej;

    private BigDecimal damage;

    private BigDecimal shYz;

    private BigDecimal shYzA;

    private BigDecimal shYzB;

    private BigDecimal shLeftPro;

    private BigDecimal shZhuan;

    private BigDecimal shTa;

    private BigDecimal shJy;

    private BigDecimal shJyA;

    private BigDecimal shJyB;

    private BigDecimal shTlz;

    public ComputePojo() {
    }

    public ComputePojo(String liupai, String sdsej) {
        this.liupai = liupai;
        this.sdsej = "on".equals(sdsej);
    }

    public void addDamage(BigDecimal damage) {
        if (this.damage == null) {
            this.damage = damage;
        } else {
            this.damage = this.damage.add(damage);
        }
    }

    public void addShYz(BigDecimal shYz) {
        if (this.shYz == null) {
            this.shYz = shYz;
        } else {
            this.shYz = this.shYz.add(shYz);
        }
        addDamage(shYz);
    }

    public void addShYzA(BigDecimal shYzA) {
        if (this.shYzA == null) {
            this.shYzA = shYzA;
        } else {
            this.shYzA = this.shYzA.add(shYzA);
        }
    }

    public void addShYzB(BigDecimal shYzB) {
        if (this.shYzB == null) {
            this.shYzB = shYzB;
        } else {
            this.shYzB = this.shYzB.add(shYzB);
        }
    }

    public void addShLeftPro(BigDecimal shLeftPro) {
        if (this.shLeftPro == null) {
            this.shLeftPro = shLeftPro;
        } else {
            this.shLeftPro = this.shLeftPro.add(shLeftPro);
        }
        addDamage(shLeftPro);
    }

    public void addShZhuan(BigDecimal shZhuan) {
        if (this.shZhuan == null) {
            this.shZhuan = shZhuan;
        } else {
            this.shZhuan = this.shZhuan.add(shZhuan);
        }
        addDamage(shZhuan);
    }

    public void addShTa(BigDecimal shTa) {
        if (this.shTa == null) {
            this.shTa = shTa;
        } else {
            this.shTa = this.shTa.add(shTa);
        }
        addDamage(shTa);
    }

    public void addShJy(BigDecimal shJy) {
        if (this.shJy == null) {
            this.shJy = shJy;
        } else {
            this.shJy = this.shJy.add(shJy);
        }
        addDamage(shJy);
    }

    public void addShJyA(BigDecimal shJyA) {
        if (this.shJyA == null) {
            this.shJyA = shJyA;
        } else {
            this.shJyA = this.shJyA.add(shJyA);
        }
    }

    public void addShJyB(BigDecimal shJyB) {
        if (this.shJyB == null) {
            this.shJyB = shJyB;
        } else {
            this.shJyB = this.shJyB.add(shJyB);
        }
    }

    public void addShTlz(BigDecimal shTlz) {
        if (this.shTlz == null) {
            this.shTlz = shTlz;
        } else {
            this.shTlz = this.shTlz.add(shTlz);
        }
        addDamage(shTlz);
    }

    public ComputeVo getVo() {
        String format = "%.0f";
        String format1 = "%.2f";
        ComputeVo vo = new ComputeVo();
        vo.setLiupai(liupai);
        vo.setDps(String.format(format, damage.divide(new BigDecimal("300"), BigDecimal.ROUND_HALF_UP)));
        vo.setShYz(String.format(format, shYz));
        vo.setShYzA(String.format(format, shYzA));
        vo.setShYzB(String.format(format, shYzB));
        vo.setZbYz(String.format(format1, shYz.divide(damage, BigDecimal.ROUND_HALF_UP)));
        vo.setShJy(String.format(format, shJy));
        vo.setShJyA(String.format(format, shJyA));
        vo.setShJyB(String.format(format, shJyB));
        vo.setZbJy(String.format(format1, shJy.divide(damage, BigDecimal.ROUND_HALF_UP)));
        vo.setShJfPro(String.format(format, shLeftPro));
        vo.setShTa(String.format(format, shTa));
        vo.setShTlz(String.format(format, shTlz));
        if (shZhuan != null) {
            vo.setShZhuan(String.format(format, shZhuan));
            vo.setZbZhuan(String.format(format1, shZhuan.divide(damage, BigDecimal.ROUND_HALF_UP)));
        }
        return vo;
    }

    public String getLiupai() {
        return liupai;
    }

    public boolean isSdsej() {
        return sdsej;
    }
}
